<?php
namespace app\api\controller;
use app\common\controller\Frontend;
use EasyWeChat\Factory;
use think\Log;
use think\Session;
/**
 * 账户中心
 */
class Api extends Frontend{
    
    protected function _initialize(){
        parent::_initialize();
        $wechat = Factory::officialAccount(config('wechat'));
        if($this->auth->isLogin() == false){
            if(!Session::get('lifeOpenid')){
               $redirect =  $wechat->oauth->scopes(['snsapi_base'])->redirect(url('mpwechat/baseoauth',['skip'=>str_replace('_','_',$this->path)],false,true));
               $this->redirect($redirect);
               exit();
            }
        }
        $wxConfig = $wechat->jssdk->buildConfig([
            'scanQRCode','getLocation','hideOptionMenu','showOptionMenu','updateAppMessageShareData','updateTimelineShareData'
        ]);
        $this->assign('wxConfig',$wxConfig);
    }

    public function index(){
        return $this->view->fetch();
    }
}